

import java.util.ArrayList;

import logic.MySQLconnection;
import Entities.RequestEntity;
import fit.ActionFixture;
import gui.AcademicFrame;
import gui.ServerGui;


public class CreateRequest extends ActionFixture
{
	RequestEntity request;
	
	ServerGui server;
	AcademicFrame client;
	public void setupfixture()
	{
		request = new RequestEntity();
		server = new ServerGui();
		server.fakeServer(5555, "mysql://localhost/test", "root", "Braude");
		server.myLog.setVisible(false);
		client = new AcademicFrame("Localhost",5555);
		
		request.setCurrentStatusDescription("Something");
		request.setOfferedChangeDescription("Something");
		request.setExplanation("Something");
		request.setRemarks("Something");
		request.setFirstName("Idan");
		request.setLastName("Mann");
		request.setTitle("Title");
		request.setEmail("123@123.com");
		request.setDate("11/11/2013");
		request.setFileName(null);
		request.setUid("100");
		request.setSystem("Moodle");
		
	}
	
	public void requestSystem (String system)
	{
		request.setSystem(system);
	}
	
	public void requestCurrentStatusDescription(String description)
	{
		request.setCurrentStatusDescription(description);
	}
	
	public void requestChangeDescription(String description)
	{
		request.setOfferedChangeDescription(description);
	}

	public void requestExplanation (String explanation)
	{
		request.setExplanation(explanation);
	}
	
	public void requestRemarks (String remarks)
	{
		request.setRemarks(remarks);
	}
	
	public boolean requestChange()
	{
		
				
		ArrayList<Object> question = new ArrayList<Object>();
		ArrayList<Object> answer = new ArrayList<Object>();
		
		int fileLength=0;
		byte[] bytes = new byte[0];
		question.add("Request");
		question.add(request);
		question.add(bytes);
		question.add(fileLength);
		client.answer=null;
		client.myclient.sendMessageToServer(question);	
		while (client.answer==null);
		answer = client.answer;
		client.answer=null;
		
		if ( ((String)(answer.get(1))).equalsIgnoreCase("Valid") )
			return true;
		else // Invalid
			return false;
		
	}
	
}








